home *** CD-ROM | disk | FTP | other *** search
- ;-------------------------oct16in routine begins--------------------------+
- ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
- ; page : 45
- ;
- ; NAME OCT16IN
- ; ROUTINE FOR conversion from ASCII octal to 16-bit Binary
- ;
- ; FUNCTION: This routine accepts an octal number from the standard input
- ; device and converts it to internal 16-bit binary form.
- ; INPUT: The individual digits of the octal number are received in ASCII
- ; through a call to a standard I/O routine. The valid digits are 0 - 7.
- ; An ASCII code other than for a valid digit will terminate the routine.
- ;
- ; OUTPUT: A 16-bit binary number is returned in the DX register.
- ; REGISTERS USED: Only DX is modified. It returns the result.
- ; SEGMENTS REFERENCED: None
- ; ROUTINES CALLED: STDIN
- ; SPECIAL NOTES: None
- ;
- ; ROUTINE TO CONVERT FROM ASCII OCTAL TO INTERNAL 16-BIT BINARY
- ;
- oct16in proc far
- ;
- push cx ; save registers
- push ax
- ;
- mov dx,0 ; initialize DX
- ;
- oct16in1:
- call stdin ; a digit comes in in AL
- sub al,30h ; reduce from ASCII
- jl oct16in2 ; check if too low
- cmp al,7
- jg oct16in2 ; check if too high
- cbw ; convert to word
- ;
- mov cl,3
- sal dx,cl ; shift dx left once
- add dx,ax ; add in digit
- jmp oct16in1
- ;
- oct16in2:
- ;
- pop ax ; restore registers
- pop cx
- ret ; return
- ;
- oct16in endp
- ;-------------------------oct16in routine ends---------------------------+